package com.asiainfo.www.pojo

import com.alibaba.fastjson.JSON

case class ConfigSource(channel:String,
                       registerDate:String,
                       historyPurchaseTimes:Int,
                       maxPurchasePathLength:Int) extends Serializable{
}

object ConfigSource{
  // {"channel":"APP","registerDate":"2019-01-01","historyPurchaseTimes":0,"maxPurchasePathLength":1}
  def buildConfig(configStr: String):ConfigSource  = {
    var config:ConfigSource = null
    try {
      val event = JSON.parseObject(configStr)
      config = ConfigSource(event.getString("channel"),event.getString("registerDate"),event.getInteger("historyPurchaseTimes"),event.getInteger("maxPurchasePathLength"))
    } catch {
      case e: Exception =>
        e.printStackTrace()
    }
    // Constants.CONFIG = config
    config
  }

}